/*
 * Copyright  bocmbci
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *     http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */
import Ability from '@ohos.app.ability.Ability';
import { CordovaPlugin } from './CordovaPlugin';

/**
 * The Ability interface that is implemented by Cordova Ability.
 * It is used to isolate plugin development, and remove dependency on entire Cordova library.
 */
export interface CordovaInterface{

  /**
   * Get the HarmonyOS Ability.
   *
   * If a custom engine lives outside of the Ability's lifecycle the return value may be null.
   *
   * @return the Ability
   */
  getAbility(): Ability | null;

  /**
   * Get the HarmonyOS context.
   *
   * @return the Context
   */
  getContext(): Context;

  /**
   * Called when a message is sent to plugin.
   *
   * @param id            The message id
   * @param data          The message data
   * @return              Object or null
   */
  onMessage(id: string, data: any): any;


  /**
   * Sends a permission request to the Ability for one permission.
   */
  requestPermission(plugin: CordovaPlugin, requestCode: number, permission: string): void;

  /**
   * Sends a permission request to the Ability for a group of permissions
   */
  requestPermissions(plugin: CordovaPlugin, requestCode: number, permissions: string[]): void;

  /**
   * Check for a permission. Returns true if the permission is granted, false otherwise.
   */
  hasPermission(permission: string): boolean;

}